﻿namespace IceCS.DesignPattern.Core.SingletonPattern.Month
{
    /// <summary>
    /// 双检锁/双重校验锁（DCL，即 double-checked locking） 双重锁
    /// </summary>
    public class MonthManager
    {
        private MonthManager()
        {
            InitCounter += 1;
        }

        private static MonthManager _manager;
        private static readonly object _lockObj = new object();
        public static int InitCounter;
        public static MonthManager Instance
        {
            get
            {
                if (_manager == null)
                {
                    lock (_lockObj)
                    {
                        if (_manager == null)
                        {

                            _manager = new MonthManager();
                        }
                    }
                }
                return _manager;
            }
        }

        public string GetJanuary()
        {
            return "January";
        }

        public string GetJanuaryNumber()
        {
            return "1";
        }

        public string GetFebruary()
        {
            return "February";
        }

        public string GetFebruaryNumber()
        {
            return "2";
        }
    }
}
